<?php


namespace App\Models;

/**
 * 用户交易记录
 * Class UserBill
 *
 * @package App\Models
 * @property int $id
 * @property int $uid
 * @property string $link_id
 * @property int $pm
 * @property string $title
 * @property string $category
 * @property string $type
 * @property string $number
 * @property string $balance
 * @property string $mark
 * @property int $status
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property \Illuminate\Support\Carbon|null $created_at
 * @method static \Illuminate\Database\Eloquent\Builder|UserBill newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|UserBill newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|UserBill query()
 * @method static \Illuminate\Database\Eloquent\Builder|UserBill whereBalance($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserBill whereCategory($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserBill whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserBill whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserBill whereLinkId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserBill whereMark($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserBill whereNumber($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserBill wherePm($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserBill whereStatus($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserBill whereTitle($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserBill whereType($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserBill whereUid($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserBill whereUpdatedAt($value)
 * @mixin \Eloquent
 */
class UserBill extends BaseModel
{
    protected $guarded = [];
    protected $appends = ['remark'];
    /**
     * @param $title
     * @param $uid
     * @param $category
     * @param $type
     * @param $number
     * @param int $link_id
     * @param int $balance
     * @param string $mark
     * @param int $status
     * @param int $pm
     * @return bool
     */
    public static function expend($title, $uid, $category, $type, $number, $link_id = 0, $balance = 0, $mark = '', $status = 1, $pm = 0)
    {
        $data = [
            'title' => (string)($title),
            'uid' => (int)($uid),
            'link_id' => (int)($link_id),
            'category' => (string)($category),
            'type' => (string)($type),
            'number' => (float)($number),
            'balance' => (float)($balance),
            'mark' => (string)($mark),
            'status' => (int)($status),
            'pm' => (int)($pm),
        ];

        $model = new self();
        $model->fill($data);
        return $model->save();
    }
}
